import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace AiKnowledgeTagApi {
  /** 知识库标签信息 */
  export interface KnowledgeTag {
    id: number; // 知识库标签ID
    name?: string; // 标签名称
    icon: string; // 标签图标
    color: string; // 颜色
    sort: number; // 排序
    systemFlag?: boolean; // 是否系统内置
    knowledgeCount: number; // 知识库个数
  }
}

/** 查询知识库标签分页 */
export function getKnowledgeTagPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<AiKnowledgeTagApi.KnowledgeTag>>(
    '/ai/knowledge-tag/page',
    data,
    { desensitize, encrypt },
  );
}

/** 查询知识库标签详情 */
export function getKnowledgeTag(id: number) {
  return requestClient.get<AiKnowledgeTagApi.KnowledgeTag>(
    `/ai/knowledge-tag/get?id=${id}`,
  );
}

/** 新增知识库标签 */
export function createKnowledgeTag(data: AiKnowledgeTagApi.KnowledgeTag) {
  return requestClient.post('/ai/knowledge-tag/create', data);
}

/** 修改知识库标签 */
export function updateKnowledgeTag(data: AiKnowledgeTagApi.KnowledgeTag) {
  return requestClient.put('/ai/knowledge-tag/update', data);
}

/** 删除知识库标签 */
export function deleteKnowledgeTag(id: number) {
  return requestClient.delete(`/ai/knowledge-tag/delete?id=${id}`);
}

/** 批量删除知识库标签 */
export function deleteKnowledgeTagList(ids: number[]) {
  return requestClient.delete(
    `/ai/knowledge-tag/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出知识库标签 */
export function exportKnowledgeTag(params: any) {
  return requestClient.download('/ai/knowledge-tag/export-excel', { params });
}
